
namespace AlertMail
{
    using System;
    using System.Configuration;
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Start to send email...");
            try
            {
                                
                string schedule = args[1];
                string type = args[0];
                switch(type)
                { 
                    case "B":
                        Console.WriteLine("to Users (Bulk Emails)");
                        string pathEmailTemplate = 
                        ConfigurationManager.AppSettings[
                        "EmailTemplate"].ToString();
                        IBulkEmail jsBulk = new BulkEmail(
                        pathEmailTemplate);
                        jsBulk.SendBulkEmailToUsers();
                        break;
                    case "J":
                        Console.WriteLine("to Jobseekers");               
                        IJobSekeerAlert jsAlert = new JobSeekerAlert();
                        jsAlert.SendEmailToJobSeekers(schedule);
                        break;
                    case "R":
                        Console.WriteLine("to Recruiters");    
                        IRecruiterAlert rcAlert = new RecruiterAlert();
                        rcAlert.SendEmailToRecruiters(schedule);
                        break;
                    case "N":
                        Console.WriteLine("to Users (Newsletter)");    
                        INewsletter newsletter = new Newsletter();
                        newsletter.SendEmailToUsers();
                        break;
                }
            }           
            catch(Exception ex)
            {
                WriteErrorToFile(ex);
            }
            Console.WriteLine("Successful.");
            Console.ReadLine();
        }
        static void WriteErrorToFile(Exception ex)
        {
            try
            {
                LogTrace.LogTraceProvider logTrace = 
                new LogTrace.LogTraceProvider();
                logTrace.WriteErrorToLogFile(ex.Message);
                Console.WriteLine(ex.Message);
            }
            catch  
            {
                 
            }
        
        }
    }
}
